#!/bin/python
import numpy as np
import matplotlib.pyplot as plt

def mysubplots(abbrev, fname, figabbrev):
    data = np.loadtxt(abbrev + fname)
    fname = fname.split('.')[0]
    dim = data.shape[1]
    f, ax = plt.subplots(2, 2)
    f.suptitle(fname)
    ax[0, 0].plot(data[:, dim / 4])
    ax[0, 0].set_title('xgrid %d' %(dim/4))
    ax[0, 1].plot(data[:, dim / 2])
    ax[0, 1].set_title('xgrid %d' %(dim/2))
    ax[1, 0].plot(data[:, dim * 3 / 4])
    ax[1, 0].set_title('xgrid %d' %(dim * 3 / 4))
    ax[1, 1].plot(data[dim/2, :dim])
    ax[1, 1].set_title("ygrid %d" %(dim / 2))
    plt.savefig(figabbrev + fname + "_subplots.eps")
    plt.close()
    plt.imshow(data)
    plt.colorbar(shrink = .5)
    plt.title(fname)
    plt.xlabel('x')
    plt.ylabel('y')
    plt.savefig(figabbrev + fname + ".eps")
    plt.close()
